# eric7.QScintilla.MiniEditor

Module implementing an editor for simple editing tasks.

### Global Attributes

None

### Classes

MiniEditor | Class implementing an editor for simple editing tasks.
MiniScintilla | Class implementing a QsciScintillaCompat subclass for handling focus events.

### Functions

None

## MiniEditor

Class implementing an editor for simple editing tasks.

### Signals

closing()
  emitted when the editor is closed
cursorLineChanged(int)
  emitted when the cursor line was changed
editorRenamed(str)
  emitted after the editor got a new name (i.e. after a 'Save As')
editorSaved()
  emitted after the file has been saved
languageChanged(str)
  emitted when the editors language was set. The language is passed as a parameter.
refreshed()
  dummy signal to emulate the Editor interface

### Derived from

EricMainWindow

### Class Attributes

isPyFile

### Class Methods

None

### Methods

MiniEditor | Constructor
__about | Private slot to show a little About message.
__aboutQt | Private slot to handle the About Qt dialog.
__bindLexer | Private slot to set the correct lexer depending on language.
__bindName | Private method to generate a dummy filename for binding a lexer.
__checkActions | Private slot to check some actions for their enable/disable status and set the statusbar info.
__checkLanguage | Private method to check the selected language of the language submenu.
__contextMenuRequested | Private slot to show the context menu.
__convertTabs | Private slot to convert tabulators to spaces.
__createActions | Private method to create the actions.
__createConfigActions | Private method to create the Settings actions.
__createEditActions | Private method to create the Edit actions.
__createFileActions | Private method to create the File actions.
__createHelpActions | Private method to create the Help actions.
__createMenus | Private method to create the menus of the menu bar.
__createSearchActions | Private method defining the user interface actions for the search commands.
__createStatusBar | Private method to initialize the status bar.
__createToolBars | Private method to create the various toolbars.
__createViewActions | Private method to create the View actions.
__cursorPositionChanged | Private slot to handle the cursorPositionChanged signal.
__deselectAll | Private slot handling the deselect all context menu action.
__documentWasModified | Private slot to handle a change in the documents modification status.
__editorChanged | Private slot handling changes of the editor language or file name.
__getCurrentWord | Private method to get the word at the current position.
__getEditorConfig | Private method to get the requested option via EditorConfig.
__getOverrideValue | Private method to get an override value for the current file type.
__getWord | Private method to get the word at a position.
__initContextMenu | Private method used to setup the context menu.
__initContextMenuLanguages | Private method used to setup the Languages context sub menu.
__languageMenuTriggered | Private method to handle the selection of a lexer language.
__loadConfiguration | Private slot to load the configuration.
__loadEditorConfig | Private method to load the EditorConfig properties.
__loadEditorConfigObject | Private method to load the EditorConfig properties for the given file name.
__loadFile | Private method to load the given file.
__markOccurrences | Private method to mark all occurrences of the current word.
__maybeSave | Private method to ask the user to save the file, if it was modified.
__modificationChanged | Private slot to handle the modificationChanged signal.
__newFile | Private slot to create a new file.
__open | Private slot to open a file.
__preferencesChanged | Private slot to handle a configuration change.
__printFile | Private slot to print the text.
__printPreview | Private slot to generate a print preview.
__printPreviewFile | Private slot to show a print preview of the text.
__readSettings | Private method to read the settings remembered last time.
__readShortcut | Private function to read a single keyboard shortcut from the settings.
__redo | Private method to redo the last recorded change.
__resetChangeTimer | Private slot to reset the parse timer.
__resetLanguage | Private method used to reset the language selection.
__resizeLinenoMargin | Private slot to resize the line numbers margin.
__save | Private slot to save a file.
__saveAs | Private slot to save a file with a new name.
__saveCopy | Private slot to save a copy of the file with a new name.
__saveDeviceFile | Private method to save the text to a file on the connected device.
__saveFile | Private method to save to the given file.
__searchClearMarkers | Private method to clear the search markers of the active window.
__searchNext | Private slot to handle the search next action.
__searchPrev | Private slot to handle the search previous action.
__selectAll | Private slot handling the select all context menu action.
__selectPygmentsLexer | Private method to select a specific pygments lexer.
__setCurrentFile | Private method to register the file name of the current file.
__setEolMode | Private method to configure the eol mode of the editor.
__setMargins | Private method to configure the margins.
__setMonospaced | Private method to set/reset a monospaced font.
__setSbFile | Private method to set the file info in the status bar.
__setTabAndIndent | Private method to set indentation size and style and tab width.
__setTextDisplay | Private method to configure the text display.
__showContextMenuLanguages | Private slot handling the aboutToShow signal of the languages context menu.
__showLanguagesMenu | Private slot to show the Languages menu of the status bar.
__showPreferences | Private slot to set the preferences.
__strippedName | Private method to return the filename part of the given path.
__styleNeeded | Private slot to handle the need for more styling.
__undo | Private method to undo the last recorded change.
__whatsThis | Private slot called in to enter Whats This mode.
__writeFile | Private method to write the current editor text to a file.
__writeSettings | Private method to write the settings for reuse.
__zoom | Private method to handle the zoom action.
__zoomIn | Private method to handle the zoom in action.
__zoomOut | Private method to handle the zoom out action.
__zoomReset | Private method to reset the zoom factor.
__zoomTo | Private slot to zoom to a given value.
activeWindow | Public method to fulfill the ViewManager interface.
clearSearchIndicators | Public method to clear all search indicators.
clearSearchSelectionHighlight | Public method to clear all highlights.
closeEvent | Protected method to handle the close event.
getFileName | Public method to return the name of the file being displayed.
getLanguage | Public method to retrieve the language of the editor.
getSRHistory | Public method to get the search or replace history list.
getSearchSelectionHighlight | Public method to get the start and end of the selection highlight.
gotoLine | Public slot to jump to the beginning of a line.
highlightSearchSelection | Public method to set a highlight for the selection at the start of a search.
isMicroPythonFile | Public method to return a flag indicating a MicroPython file.
isPy3File | Public method to return a flag indicating a Python3 file.
setFileName | Public method to set the file name of the file being displayed.
setLanguage | Public method to set a lexer language.
setModified | Public method to set the editor modification state.
setSearchIndicator | Public method to set a search indicator for the given range.
setText | Public method to set the text programatically.
setWindowModified | Public method to set the window modification status.
show | Public method to show the editor window and complete the initial setup.
showReplaceWidget | Public method to show the replace widget.
showSearchWidget | Public method to show the search widget.
textForFind | Public method to determine the selection or the current word for the next find operation.

### Static Methods

None

#### MiniEditor (Constructor)

MiniEditor(filename="", filetype="", parent=None, name=None)

Constructor

filename (str)
  name of the file to open
filetype (str)
  type of the source file
parent (QWidget)
  reference to the parent widget
name (str)
  object name of the window

#### MiniEditor.__about

__about()

Private slot to show a little About message.

#### MiniEditor.__aboutQt

__aboutQt()

Private slot to handle the About Qt dialog.

#### MiniEditor.__bindLexer

__bindLexer(filename, pyname="")

Private slot to set the correct lexer depending on language.

filename (str)
  filename used to determine the associated lexer language
pyname (str)
  name of the pygments lexer to use

#### MiniEditor.__bindName

__bindName(line0)

Private method to generate a dummy filename for binding a lexer.

line0 (str)
  first line of text to use in the generation process

Return:
  dummy file name to be used for binding a lexer

Return Type:
  str

#### MiniEditor.__checkActions

__checkActions(setSb=True)

Private slot to check some actions for their enable/disable status and set the statusbar info.

setSb (bool)
  flag indicating an update of the status bar is wanted

#### MiniEditor.__checkLanguage

__checkLanguage()

Private method to check the selected language of the language submenu.

#### MiniEditor.__contextMenuRequested

__contextMenuRequested(coord)

Private slot to show the context menu.

coord (QPoint)
  the position of the mouse pointer

#### MiniEditor.__convertTabs

__convertTabs()

Private slot to convert tabulators to spaces.

#### MiniEditor.__createActions

__createActions()

Private method to create the actions.

#### MiniEditor.__createConfigActions

__createConfigActions()

Private method to create the Settings actions.

#### MiniEditor.__createEditActions

__createEditActions()

Private method to create the Edit actions.

#### MiniEditor.__createFileActions

__createFileActions()

Private method to create the File actions.

#### MiniEditor.__createHelpActions

__createHelpActions()

Private method to create the Help actions.

#### MiniEditor.__createMenus

__createMenus()

Private method to create the menus of the menu bar.

#### MiniEditor.__createSearchActions

__createSearchActions()

Private method defining the user interface actions for the search commands.

#### MiniEditor.__createStatusBar

__createStatusBar()

Private method to initialize the status bar.

#### MiniEditor.__createToolBars

__createToolBars()

Private method to create the various toolbars.

#### MiniEditor.__createViewActions

__createViewActions()

Private method to create the View actions.

#### MiniEditor.__cursorPositionChanged

__cursorPositionChanged(line, pos)

Private slot to handle the cursorPositionChanged signal.

line (int)
  line number of the cursor
pos (int)
  position in line of the cursor

#### MiniEditor.__deselectAll

__deselectAll()

Private slot handling the deselect all context menu action.

#### MiniEditor.__documentWasModified

__documentWasModified()

Private slot to handle a change in the documents modification status.

#### MiniEditor.__editorChanged

__editorChanged()

Private slot handling changes of the editor language or file name.

#### MiniEditor.__getCurrentWord

__getCurrentWord()

Private method to get the word at the current position.

Return:
  the word at that current position

Return Type:
  str

#### MiniEditor.__getEditorConfig

__getEditorConfig(option, nodefault=False, config=None)

Private method to get the requested option via EditorConfig.

If there is no EditorConfig defined, the equivalent built-in option will be used (Preferences.getEditor(). The option must be given as the Preferences option key. The mapping to the EditorConfig option name will be done within this method.

option (str)
  Preferences option key
nodefault (bool)
  flag indicating to not get the default value from Preferences but return None instead
config (dict)
  reference to an EditorConfig object or None

Return:
  value of requested setting or None if nothing was found and nodefault parameter was True

Return Type:
  Any

#### MiniEditor.__getOverrideValue

__getOverrideValue(option)

Private method to get an override value for the current file type.

option (str)
  Preferences option key

Return:
  override value; None in case nothing is defined

Return Type:
  Any

#### MiniEditor.__getWord

__getWord(line, index)

Private method to get the word at a position.

line (int)
  number of line to look at
index (int)
  position to look at

Return:
  the word at that position

Return Type:
  str

#### MiniEditor.__initContextMenu

__initContextMenu()

Private method used to setup the context menu.

#### MiniEditor.__initContextMenuLanguages

__initContextMenuLanguages()

Private method used to setup the Languages context sub menu.

Return:
  reference to the generated menu

Return Type:
  QMenu

#### MiniEditor.__languageMenuTriggered

__languageMenuTriggered(act)

Private method to handle the selection of a lexer language.

act (QAction)
  reference to the action that was triggered

#### MiniEditor.__loadConfiguration

__loadConfiguration()

Private slot to load the configuration.

#### MiniEditor.__loadEditorConfig

__loadEditorConfig(fileName="")

Private method to load the EditorConfig properties.

fileName (str)
  name of the file

#### MiniEditor.__loadEditorConfigObject

__loadEditorConfigObject(fileName)

Private method to load the EditorConfig properties for the given file name.

fileName (str)
  name of the file

Return:
  EditorConfig dictionary

Return Type:
  dict

#### MiniEditor.__loadFile

__loadFile(fileName, filetype=None)

Private method to load the given file.

fileName (str)
  name of the file to load
filetype (str)
  type of the source file

#### MiniEditor.__markOccurrences

__markOccurrences()

Private method to mark all occurrences of the current word.

#### MiniEditor.__maybeSave

__maybeSave()

Private method to ask the user to save the file, if it was modified.

Return:
  flag indicating, if it is ok to continue

Return Type:
  bool

#### MiniEditor.__modificationChanged

__modificationChanged(m)

Private slot to handle the modificationChanged signal.

m (bool)
  modification status

#### MiniEditor.__newFile

__newFile()

Private slot to create a new file.

#### MiniEditor.__open

__open()

Private slot to open a file.

#### MiniEditor.__preferencesChanged

__preferencesChanged()

Private slot to handle a configuration change.

#### MiniEditor.__printFile

__printFile()

Private slot to print the text.

#### MiniEditor.__printPreview

__printPreview(printer)

Private slot to generate a print preview.

printer (QScintilla.Printer.Printer)
  reference to the printer object

#### MiniEditor.__printPreviewFile

__printPreviewFile()

Private slot to show a print preview of the text.

#### MiniEditor.__readSettings

__readSettings()

Private method to read the settings remembered last time.

#### MiniEditor.__readShortcut

__readShortcut(act, category)

Private function to read a single keyboard shortcut from the settings.

act (EricAction)
  reference to the action object
category (str)
  category the action belongs to

#### MiniEditor.__redo

__redo()

Private method to redo the last recorded change.

#### MiniEditor.__resetChangeTimer

__resetChangeTimer()

Private slot to reset the parse timer.

#### MiniEditor.__resetLanguage

__resetLanguage()

Private method used to reset the language selection.

#### MiniEditor.__resizeLinenoMargin

__resizeLinenoMargin()

Private slot to resize the line numbers margin.

#### MiniEditor.__save

__save()

Private slot to save a file.

Return:
  flag indicating success

Return Type:
  bool

#### MiniEditor.__saveAs

__saveAs()

Private slot to save a file with a new name.

Return:
  flag indicating success

Return Type:
  bool

#### MiniEditor.__saveCopy

__saveCopy()

Private slot to save a copy of the file with a new name.

#### MiniEditor.__saveDeviceFile

__saveDeviceFile(saveas=False)

Private method to save the text to a file on the connected device.

saveas (bool (optional))
  flag indicating a 'save as' action (defaults to False)

Return:
  flag indicating success

Return Type:
  bool

#### MiniEditor.__saveFile

__saveFile(fileName)

Private method to save to the given file.

fileName (str)
  name of the file to save to

Return:
  flag indicating success

Return Type:
  bool

#### MiniEditor.__searchClearMarkers

__searchClearMarkers()

Private method to clear the search markers of the active window.

#### MiniEditor.__searchNext

__searchNext()

Private slot to handle the search next action.

#### MiniEditor.__searchPrev

__searchPrev()

Private slot to handle the search previous action.

#### MiniEditor.__selectAll

__selectAll()

Private slot handling the select all context menu action.

#### MiniEditor.__selectPygmentsLexer

__selectPygmentsLexer()

Private method to select a specific pygments lexer.

Return:
  name of the selected pygments lexer

Return Type:
  str

#### MiniEditor.__setCurrentFile

__setCurrentFile(fileName)

Private method to register the file name of the current file.

fileName (str)
  name of the file to register

#### MiniEditor.__setEolMode

__setEolMode()

Private method to configure the eol mode of the editor.

#### MiniEditor.__setMargins

__setMargins()

Private method to configure the margins.

#### MiniEditor.__setMonospaced

__setMonospaced(on)

Private method to set/reset a monospaced font.

on (bool)
  flag to indicate usage of a monospace font

#### MiniEditor.__setSbFile

__setSbFile(line=None, pos=None, language=None, zoom=None)

Private method to set the file info in the status bar.

line (int)
  line number to display
pos (int)
  character position to display
language (str)
  language to display
zoom (int)
  zoom value

#### MiniEditor.__setTabAndIndent

__setTabAndIndent()

Private method to set indentation size and style and tab width.

#### MiniEditor.__setTextDisplay

__setTextDisplay()

Private method to configure the text display.

#### MiniEditor.__showContextMenuLanguages

__showContextMenuLanguages()

Private slot handling the aboutToShow signal of the languages context menu.

#### MiniEditor.__showLanguagesMenu

__showLanguagesMenu(pos)

Private slot to show the Languages menu of the status bar.

pos (QPoint)
  position the menu should be shown at

#### MiniEditor.__showPreferences

__showPreferences()

Private slot to set the preferences.

#### MiniEditor.__strippedName

__strippedName(fullFileName)

Private method to return the filename part of the given path.

fullFileName (str)
  full pathname of the given file

Return:
  filename part

Return Type:
  str

#### MiniEditor.__styleNeeded

__styleNeeded(position)

Private slot to handle the need for more styling.

position (int)
  end position, that needs styling

#### MiniEditor.__undo

__undo()

Private method to undo the last recorded change.

#### MiniEditor.__whatsThis

__whatsThis()

Private slot called in to enter Whats This mode.

#### MiniEditor.__writeFile

__writeFile(fileName)

Private method to write the current editor text to a file.

fileName (str)
  name of the file to be written to

Return:
  flag indicating success

Return Type:
  bool

#### MiniEditor.__writeSettings

__writeSettings()

Private method to write the settings for reuse.

#### MiniEditor.__zoom

__zoom()

Private method to handle the zoom action.

#### MiniEditor.__zoomIn

__zoomIn()

Private method to handle the zoom in action.

#### MiniEditor.__zoomOut

__zoomOut()

Private method to handle the zoom out action.

#### MiniEditor.__zoomReset

__zoomReset()

Private method to reset the zoom factor.

#### MiniEditor.__zoomTo

__zoomTo(value)

Private slot to zoom to a given value.

value (int)
  zoom value to be set

#### MiniEditor.activeWindow

activeWindow()

Public method to fulfill the ViewManager interface.

Return:
  reference to the text edit component

Return Type:
  QsciScintillaCompat

#### MiniEditor.clearSearchIndicators

clearSearchIndicators()

Public method to clear all search indicators.

#### MiniEditor.clearSearchSelectionHighlight

clearSearchSelectionHighlight()

Public method to clear all highlights.

#### MiniEditor.closeEvent

closeEvent(event)

Protected method to handle the close event.

event (QCloseEvent)
  close event

#### MiniEditor.getFileName

getFileName()

Public method to return the name of the file being displayed.

Return:
  filename of the displayed file

Return Type:
  str

#### MiniEditor.getLanguage

getLanguage(normalized=True, forPygments=False)

Public method to retrieve the language of the editor.

normalized (bool)
  flag indicating to normalize some Pygments lexer names
forPygments (bool)
  flag indicating to normalize some lexer names for Pygments

Return:
  language of the editor

Return Type:
  str

#### MiniEditor.getSRHistory

getSRHistory(key)

Public method to get the search or replace history list.

key (str)
  list to return (must be 'search' or 'replace')

Return:
  the requested history list

Return Type:
  list of str

#### MiniEditor.getSearchSelectionHighlight

getSearchSelectionHighlight()

Public method to get the start and end of the selection highlight.

Return:
  tuple containing the start line and index and the end line and index

Return Type:
  tuple of (int, int, int, int)

#### MiniEditor.gotoLine

gotoLine(line, pos=1)

Public slot to jump to the beginning of a line.

line (int)
  line number to go to
pos (int)
  position in line to go to

#### MiniEditor.highlightSearchSelection

highlightSearchSelection(startLine, startIndex, endLine, endIndex)

Public method to set a highlight for the selection at the start of a search.

startLine (int)
  line of the selection start
startIndex (int)
  index of the selection start
endLine (int)
  line of the selection end
endIndex (int)
  index of the selection end

#### MiniEditor.isMicroPythonFile

isMicroPythonFile()

Public method to return a flag indicating a MicroPython file.

Return:
  flag indicating a MicroPython file

Return Type:
  bool

#### MiniEditor.isPy3File

isPy3File()

Public method to return a flag indicating a Python3 file.

Return:
  flag indicating a Python3 file

Return Type:
  bool

#### MiniEditor.setFileName

setFileName(name)

Public method to set the file name of the file being displayed.

name (str)
  name of the displayed file

#### MiniEditor.setLanguage

setLanguage(filename, initTextDisplay=True, pyname="")

Public method to set a lexer language.

filename (str)
  filename used to determine the associated lexer language
initTextDisplay (bool)
  flag indicating an initialization of the text display is required as well
pyname (str)
  name of the pygments lexer to use

#### MiniEditor.setModified

setModified(modified)

Public method to set the editor modification state.

modified (bool)
  new editor modification state

#### MiniEditor.setSearchIndicator

setSearchIndicator(startPos, indicLength)

Public method to set a search indicator for the given range.

startPos (int)
  start position of the indicator
indicLength (int)
  length of the indicator

#### MiniEditor.setText

setText(txt, filetype=None)

Public method to set the text programatically.

txt (str)
  text to be set
filetype (str)
  type of the source file

#### MiniEditor.setWindowModified

setWindowModified(modified)

Public method to set the window modification status.

modified (bool)
  flag indicating the modification status

#### MiniEditor.show

show()

Public method to show the editor window and complete the initial setup.

#### MiniEditor.showReplaceWidget

showReplaceWidget()

Public method to show the replace widget.

#### MiniEditor.showSearchWidget

showSearchWidget()

Public method to show the search widget.

#### MiniEditor.textForFind

textForFind()

Public method to determine the selection or the current word for the next find operation.

Return:
  selection or current word

Return Type:
  str

Up

## MiniScintilla

Class implementing a QsciScintillaCompat subclass for handling focus events.

### Derived from

QsciScintillaCompat

### Class Attributes

EncloseChars

### Class Methods

None

### Methods

MiniScintilla | Constructor
editorCommand | Public method to perform a simple editor command.
encloseSelectedText | Local function to enclose the current selection with some characters.
focusInEvent | Protected method called when the editor receives focus.
focusOutEvent | Protected method called when the editor loses focus.
getFileName | Public method to return the name of the file being displayed.
keyPressEvent | Protected method to handle the user input a key at a time.
mousePressEvent | Protected method to handle the mouse press event.
removeTrailingWhitespace | Public method to remove trailing whitespace.

### Static Methods

None

#### MiniScintilla (Constructor)

MiniScintilla(parent=None)

Constructor

parent (QWidget)
  parent widget

#### MiniScintilla.editorCommand

editorCommand(cmd)

Public method to perform a simple editor command.

cmd (int)
  the scintilla command to be performed

#### MiniScintilla.encloseSelectedText

encloseSelectedText()

Local function to enclose the current selection with some characters.

encString (str)
  string to use to enclose the selection (one or two characters)

#### MiniScintilla.focusInEvent

focusInEvent(event)

Protected method called when the editor receives focus.

This method checks for modifications of the current file and rereads it upon request. The cursor is placed at the current position assuming, that it is in the vicinity of the old position after the reread.

event (QFocusEvent)
  the event object

#### MiniScintilla.focusOutEvent

focusOutEvent(event)

Protected method called when the editor loses focus.

event (QFocusEvent)
  the event object

#### MiniScintilla.getFileName

getFileName()

Public method to return the name of the file being displayed.

Return:
  filename of the displayed file

Return Type:
  str

#### MiniScintilla.keyPressEvent

keyPressEvent(ev)

Protected method to handle the user input a key at a time.

ev (QKeyEvent)
  key event

#### MiniScintilla.mousePressEvent

mousePressEvent(event)

Protected method to handle the mouse press event.

event (QMouseEvent)
  the mouse press event

#### MiniScintilla.removeTrailingWhitespace

removeTrailingWhitespace()

Public method to remove trailing whitespace.

Up